import requests

# 登录成功，获取令牌
resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/login",
                     json={"mobile": "13800000002", "password": "123456"})
token = resp.json().get("data")

# 添加员工
resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                     headers={"Content-Type": "application/json",
                              "Authorization": token},
                     json={
                         "username": "张三疯007",
                         "mobile": "18989089001",
                         "workNumber": "9527"
                     })
print("添加员工：", resp.json())

# 查询员工
resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/1545374764246249472",
                    headers={"Authorization": token})
print("查询员工：", resp.json())

# 修改员工
resp = requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/1545374764246249472",
                    headers={"Authorization": token},
                    json={"username": "至宗宝99"})
print("修改员工：", resp.json())

# 删除员工
resp = requests.delete(url="http://ihrm2-test.itheima.net/api/sys/user/1545374764246249472",
                       headers={"Authorization": token})
print("删除员工：", resp.json())
